package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFile;
import com.sky.dto.SetmealPageQueryDTO;
import com.sky.entity.Setmeal;
import com.sky.entity.SetmealDish;
import com.sky.enumeration.OperationType;
import com.sky.vo.SetmealVO;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper

public interface SetmealMapper {

    @ApiOperation("新增套餐")
    @AutoFile(OperationType.INSERT)
    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into setmeal (category_id, name, price, description, image, create_time, update_time, create_user, update_user) VALUES" +
            "(#{categoryId},#{name},#{price},#{description},#{image},#{createTime},#{updateTime},#{createUser},#{updateUser})")
    void insert(Setmeal setmeal);


    @ApiOperation("套餐分页查询")
    Page<SetmealVO> pageQuery(SetmealPageQueryDTO setmealPageQueryDTO);

    @ApiOperation("根据id查询套餐")
    @Select("select * from setmeal where id = #{id}")
    Setmeal getById(Long id);

    @ApiOperation("根据id删除套餐")
    @Select("delete from setmeal where id = #{id}")
    void deleteById(Long id);

    @ApiOperation("修改套餐")
    @AutoFile(OperationType.UPDATE)
    void update(Setmeal setmeal);
}
